<template>
    <div>
      <p class="title">历史导入进度，共{{total}}条</p>
      <el-table
        :data="tableData"
        style="width: 100%;margin-top: 20px">
        <el-table-column
          prop="formName"
          label="表格名称">
        </el-table-column>
        <el-table-column
          prop="createDate"
          label="导入时间">
        </el-table-column>
        <el-table-column
          prop="name"
          label="导入状态">
          <template slot-scope="scope">
            <div>
              <span v-if="scope.row.impStatus == 1" class="success">导入成功</span>
              <span v-if="scope.row.impStatus == 2" class="error">导入失败</span>
              <span v-if="scope.row.impStatus == 3" class="warning">导入完成</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          label="操作">
          <template slot-scope="scope">
            <span style="cursor: pointer" @click="toDetail(scope.row.id)" v-if="scope.row.impStatus == 2 || scope.row.impStatus == 3">
              查看详情
            </span>
          </template>
        </el-table-column>
      </el-table>

      <div class="footer">
        <el-pagination align="right" class="fixed"
                       @size-change="handleSizeChange"
                       @current-change="handleCurrentChange"
                       :current-page.sync="nowPage"
                       :page-sizes="[10, 20, 30, 50]"
                       :page-size="nowSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="total">
        </el-pagination>
      </div>


    </div>
</template>

<script>
  import {custImpList} from '@/api/customer'
    export default {
        name: "importList",
        data() {
            return {
                tableData: [],
                total:1,
                nowSize:10,
                nowPage:1
            }
        },
        methods:{
            init() {
                custImpList(this.nowPage, this.nowSize).then(res => {
                   if(res.data.success) {
                       this.tableData = res.data.data.records
                       this.total = res.data.data.total
                   }
                })
            },
            handleSizeChange(size) {
                this.nowSize = size
                this.nowPage = 1
                this.init()
            },
            handleCurrentChange(page) {
                this.nowPage = page
                this.init()
            },
            toDetail(id) {
                this.$router.push(`/customer/import/detail/${id}`)
            }
        }
    }
</script>

<style scoped>
.title{
  font-weight: 600;
}
  .success {
    color: #67c23a;
  }
  .warning{
    color: #e6a23c;
  }
  .error{
    color: #f56c6c;
  }
</style>
